import java.util.ArrayList;  
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.LinkedList;

import javax.swing.*;
/** 
 * 
 * @author  botelhodaniel 
 */  
public class tela extends JFrame {
  
    /** Creates new form SaveSession */  
  
    public tela() {
        //título da tela
        this.setTitle("Simulador de MIPS");

        //tamanho da tela
        this.setSize(300,300);

        //coloca a tela no centro
        this.setLocationRelativeTo(null);
        

        initComponents();  
        trataFilechooser();  
        close();  
    }  
    private void close() {  
        setVisible(false);  
        dispose();  
    }  
    private void trataFilechooser() {
        ArrayList retorno = new ArrayList(); 
        int retVal = jFileChooser1.showOpenDialog(this);  
        if (retVal == jFileChooser1.APPROVE_OPTION) 
          retorno = funcoes.read(jFileChooser1.getSelectedFile().getAbsolutePath());
        cpu c = new cpu();
        c.leInstrucoes(retorno);
        c.executa(cpu.MD_DIRETO);
    }  
         
    private void initComponents() {  
        jFileChooser1 = new javax.swing.JFileChooser();  
  
        addWindowListener(new java.awt.event.WindowAdapter() {  
            public void windowClosing(java.awt.event.WindowEvent evt) {  
                exitForm(evt);  
            }  
        });  
  
        jFileChooser1.setDialogType(javax.swing.JFileChooser.OPEN_DIALOG);    
        getContentPane().add(jFileChooser1, java.awt.BorderLayout.CENTER);
       
  
        pack();  
    }
    /*
    public static void main(String args[]) {  
        tela t = new tela();
        t.setVisible(true);
        
    } 
    * */
    
    
    private void exitForm(java.awt.event.WindowEvent evt) {  
        setVisible(false);  
        dispose();  
    } 
    
    private javax.swing.JFileChooser jFileChooser1; 
}
